// JavaScript Document v1.001
var OpenedFrame = '';
var xmlHttp;
var DivID;
var SecondURL = '';
var SecondDivID = '';
var isIE = document.all;
var IE = document.all ? true : false;
var tempX = 0;
var tempY = 0;
var ifjQueryui,ifjQuery
ifjQuery = false;
ifjQueryui = false;
if (typeof jQuery != "undefined") {
  ifjQuery = true;
  if (typeof jQuery.ui != "undefined") {
    ifjQueryui=true;
  }
}
	

//  ---------------------------------------
// Array.indexOf( value, begin, strict ) - Return index of the first element that matches value
Array.prototype.indexOf = function( v, b, s ) {
  for( var i = +b || 0, l = this.length; i < l; i++ ) {
    if( this[i]===v || s && this[i]==v ) {
      return i;
    }
  }
  return -1;
};

function setFullScreen(objID)
{
  var oFrame;
  var SearchPanel;
  var xWidth;
  var obj = document.getElementById(objID);
  obj.width = "95%";
  obj.height = "98%" ;

}

//  ---------------------------------------

function ResizeBody()
{
  var oBody;
  var oFrame;
  var SearchPanel;
  var xWidth;
  oFrame	 = document.body;
  xWidth = oFrame.scrollWidth + (oFrame.offsetWidth - oFrame.clientWidth) - 20;
  if (xWidth < 999)
  {
    xWidth = 999;
  }
  if (objectExists(document.getElementById("tDataArea")))
  {
    oBody	 = 	document.getElementById("tDataArea");
    oBody.style.width = xWidth + 'px';
  }
  if (objectExists(document.getElementById("SearchPanel")))
  {
    oBody	 = 	document.getElementById("SearchPanel");
    oBody.style.width = xWidth + 'px';
  }
}

//  ---------------------------------------


function CloseMe()

{
  var fObj;


  // fObj = top.document.getElementById(this.name);
  fObj = parent.document.getElementById(this.name);

  // alert(fObj.name);
  // alert(fObj.style.zIndex);
  fObj.height = 1;
  try
  {
    this.parent.location.href = this.parent.location.href;
  }
  catch(e)
  {
    window.status = 	'Error: ' + e.number + '; ' + e.description;
  }

}

//  ---------------------------------------

function loadHTMLFragment(elemId, HTMLFragment)
{
  var el;
  if (document &&
    document.getElementById &&
    document.getElementById(elemId) &&
    document.createElement &&
    document.appendChild &&
    document.getElementsByTagName)
    {
    el = document.getElementById(elemId);
    if(isIE)
    {
      HTMLFragment = "&nbsp;" + HTMLFragment;
    // The & nbsp; is a hack to cause IE to process the
    // script elements if the first node in the
    // HTMLFragment is a script element.
    }
    el.innerHTML = HTMLFragment;
    var d = el.getElementsByTagName('script');
    var t = d.length;
    var newScript ;
    var s;
    var OldScript;
    for (var x = 0; x < t; x ++ )
    {
      newScript = document.createElement('script');
      newScript.type = "text/javascript";
      if(d[x].src)
      {
        newScript.src = d[x].src;
      }
      else
      {
        if(isIE)
        {
          newScript.text = d[x].text;
        }
        else
        {
          s = document.createTextNode(d[x].text);
          newScript.appendChild(s);
        }
      }
      el.appendChild(newScript);
    }
    for (var y = 0; y < t; )
    {
      OldScript = el.getElementsByTagName("script")[0];
      //    el.removeChild(OldScript);
      OldScript.parentNode.removeChild(OldScript);
      y ++ ;
    }
  }

  document.documentElement.style.cursor = "auto";

}

//  ---------------------------------------


function viewFrame(fObjID, fType, url)
{
  var fObj;
  try
  {

    if ( OpenedFrame != fObjID && OpenedFrame !== '')
    {
      fObj = document.getElementById(OpenedFrame);
      fObj.height = 1;
    }
    OpenedFrame = fObjID;
    fObj = document.getElementById(fObjID);

    if ( self.frames[fObjID].location.href.indexOf(url) == - 1)
    {
      fObj.height = 750 ;
      //     reSize(fObj);
      self.frames[fObjID].location.href = url;
    }
    else
    {
      if (fObj.height == 750)
      {
        fObj.height = 1;
      }
      else
      {
        fObj.height = 750 ;
      }
    }
  }
  catch(e)
  {
    window.status = 	'Error: ' + e.number + '; ' + e.description;
  }

}

//  ---------------------------------------

function showInfoSPost(URL, ID, params, OnStateChanged)
{
  //debugger;
  DivID = ID;
  document.getElementById(DivID).innerHTML = 'Please wait ...';
  document.documentElement.style.cursor = "wait";
  xmlHttp = GetXmlHttpObject();
  document.getElementById(DivID).innerHTML = "Please Wait";
  xmlHttp.open("POST", URL, false);

  // Send the proper header information along with the request
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");
  // document.documentElement.style.cursor = "auto";

  xmlHttp.send(params);

  if (typeof(OnStateChanged) == 'undefined')
  {
    OnStateChanged = 'stateChanged()';
  }
  eval(OnStateChanged);

}

//  ---------------------------------------


function showInfoS(URL, ID, OnStateChanged)
{
  document.documentElement.style.cursor = "wait";
  DivID = ID;
  if (document.getElementById(DivID)== null) {
    var newDiv = document.createElement('div') 
    var target = document.getElementsByTagName('BODY')[0];
    newDiv.id = DivID;
    newDiv.style.position = "fixed";
    newDiv.style.left = "50%";
    newDiv.style.top = "50%";
    newDiv.style.margin = "-150px 0 0 -250px";
    target.appendChild(newDiv);
	   
  }
  xmlHttp = GetXmlHttpObject();
  if (xmlHttp === null)
  {
    alert (" Your browser does not support AJAX!");
    return;
  }
  // 			if (typeof(OnStateChanged) == 'undefined')
  // 			  {
  // 				  OnStateChanged = 'stateChanged';
  // 			  }
  //            xmlHttp.onreadystatechange = eval(OnStateChanged);
  document.getElementById(DivID).innerHTML = "Please Wait";
  xmlHttp.open("GET", URL, false);
  xmlHttp.send(null);

  if (typeof(OnStateChanged) == 'undefined')
  {
    OnStateChanged = 'stateChanged()';
  }
  eval(OnStateChanged);
  document.documentElement.style.cursor = "auto";

}

//  ---------------------------------------
function showInfo(URL, ID, OnStateChanged)
{
  document.documentElement.style.cursor = "wait";
  DivID = ID;
  xmlHttp = GetXmlHttpObject();
  if (xmlHttp === null)
  {
    alert (" Your browser does not support AJAX!");
    return;
  }
  if (typeof(OnStateChanged) == 'undefined')
  {
    OnStateChanged = 'stateChanged';
  }
  xmlHttp.onreadystatechange = eval(OnStateChanged);
  document.getElementById(DivID).innerHTML = "Please Wait";
  xmlHttp.open("GET", URL, true);
  xmlHttp.send(null);
}

//  ---------------------------------------

function sendAJAXPost(URL, ID, params, OnStateChanged)
{
  DivID = ID;
  document.getElementById(DivID).innerHTML = 'Please wait ...';
  document.documentElement.style.cursor = "wait";
  xmlHttp = GetXmlHttpObject();
  xmlHttp.open("POST", URL, false);

  // Send the proper header information along with the request
  xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  xmlHttp.setRequestHeader("Content-length", params.length);
  xmlHttp.setRequestHeader("Connection", "close");
  // document.documentElement.style.cursor = "auto";

  xmlHttp.send(params);

  if (typeof(OnStateChanged) == 'undefined')
  {
    OnStateChanged = stateChanged();
  }
  xmlHttp.onreadystatechange = OnStateChanged;

}

//  ---------------------------------------

function stateChanged()
{
  if (xmlHttp.readyState == 4)
  {
    // document.getElementById(DivID).innerHTML = xmlHttp.responseText;
    loadHTMLFragment(DivID, xmlHttp.responseText);
    if (SecondURL !== '')
    {
      showInfo(SecondURL, 	SecondDivID);
      SecondDivID = '';
      SecondURL = '';
      document.documentElement.style.cursor = "auto";
    }
  }
}

//  ---------------------------------------

function stateChangedNoJ()
{
  if (xmlHttp.readyState == 4)
  {
    document.getElementById(DivID).innerHTML = xmlHttp.responseText;
    if (SecondURL !== '')
    {
      showInfo(SecondURL, 	SecondDivID);
      SecondDivID = '';
      SecondURL = '';
      document.documentElement.style.cursor = "auto";
    }
  }
}

//  ---------------------------------------

function GetXmlHttpObject()
{
  var xmlHttp = null;

  try
  {
    // Firefox, Opera 8.0 + , Safari
    xmlHttp = new XMLHttpRequest();
  }
  catch (e)
  {
    // Internet Explorer
    try
    {
      xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch (e)
    {
      xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }

  return xmlHttp;
}

//  ---------------------------------------


function showDiv(div)
{
  var TopZ = GetTopDivID(div);
  if (ifjQueryui) {
    document.getElementById(div).style.display = 'none';
  }
  else
  {
    document.getElementById(div).style.display = 'block';
  }
  document.getElementById(div).style.zIndex = TopZ + 1 ;
  if (document.getElementById(div).style.position == "fixed")
  {
    var target = document.getElementsByTagName('BODY')[0];
    target.appendChild(document.getElementById(div));
  }
  if (ifjQueryui) {
    $( "#"+div ).show(200);
  }


}

//  ---------------------------------------

function hideDiv(div)
{
  document.getElementById(div).style.display = 'none';
}

//  ---------------------------------------




function objectExists(obj)
{
  if (obj === null || obj === undefined)
  {
    return false;
  }
  else
  {
    return true;
  }
}

//  ---------------------------------------

function makeWin(url, windowName , params)
{
  if (params == 'X' || params === '' || typeof(params) == 'undefined' )
  {
    params = 'scrollbars=yes,status=no,menubar=1,dependent=yes,resizable=yes,width=700,height=550,screenX=0,screenY=0,alwaysRaised=yes';
  }
  agent = navigator.userAgent;
  win = window.open(url, windowName , params);

  if (agent.indexOf("Mozilla/2") != - 1 && agent.indexOf("Win") == - 1)
  {
    win = window.open(url, windowName , params);
  }
  if ( ! win.opener)
  {
    win.opener = window;
  }
}

//  ---------------------------------------


function reSize(ifrm)
{
  var oBody	 = 	ifrm.document.body;
  var oFrame	 = 	document.all(ifrm);
  try
  {

    oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight - oBody.clientHeight);
    oFrame.style.width = oBody.scrollWidth + (oBody.offsetWidth - oBody.clientWidth);
  }
  // An error is raised if the IFrame domain != its container's domain
  catch(e)
  {
    window.status = 	'Error: ' + e.number + '; ' + e.description;
  }
}

//  ---------------------------------------

function ShowFrame(fObjID, url, objheight)
{
  var oBody;
  var fObj;
  try
  {
    oBody	 = 	parent.document.body;
    objheight = screen.height - 200;
    objheight = oBody.clientHeight  - 20;
    if ( OpenedFrame != fObjID && OpenedFrame !== '')
    {
      fObj = document.getElementById(OpenedFrame);
      fObj.height = 1;
    }
    OpenedFrame = fObjID;
    fObj = document.getElementById(fObjID);
    // fObj.width = oBody.clientWidth - 20;
    fObj.width = "95%";
    if ( self.frames[fObjID].location.href.indexOf(url) == - 1)
    {
      fObj.height = "98%" ;
      self.frames[fObjID].location.href = url;
    }
    else
    {
      if (fObj.height == objheight)
      {
        fObj.height = 1;

      }
      else
      {
        fObj.height = "98%" ;
      }
    }
  }
  catch(e)
  {
    window.status = 	'Error: ' + e.number + '; ' + e.description;
  }

}

//  ---------------------------------------

function getElementsByTagNames(list, obj)
{
  //debugger;



  if ( ! obj) var obj = document;



  var tagNames = list.split(',');



  var resultArray = new Array();



  for (var i = 0; i < tagNames.length; i ++ )



  {



      var tags = obj.getElementsByTagName(tagNames[i]);



      for (var j = 0; j < tags.length; j ++ )



      {



          resultArray.push(tags[j]);



        }



    }



  var testNode = resultArray[0];



  if (testNode.sourceIndex)



  {



    resultArray.sort(function (a, b)
    {



      return a.sourceIndex - b.sourceIndex;



    }
    )
  }
  else if (testNode.compareDocumentPosition)
  {
    resultArray.sort(function (a, b)
    {
      return 3 - (a.compareDocumentPosition(b) & 6);
    }
    )
  }
  return resultArray;
}

//  ---------------------------------------

function GetParamsInDiv(DivID)
{
  //	debugger;

  var params = "";
  var formFieldList = getElementsByTagNames('hidden,input,select,textarea,radio', document.getElementById(DivID));
  var FieldsCount = formFieldList.length;
  for (var i = 0; i < formFieldList.length; i ++ )
  {
    if  (formFieldList[i].name != 'undefined' || formFieldList[i].name !== '' )
    {
      if ( formFieldList[i].type == 'checkbox' || formFieldList[i].type == 'radio' )
      {
        if (formFieldList[i].checked)
        {
          params = params + formFieldList[i].name + '=' + escape(formFieldList[i].value) + '&';
        }
      }
      else
      {
        params = params + formFieldList[i].name + '=' + escape(formFieldList[i].value) + '&';
      }
    }
  }
  return params;
}

//  ---------------------------------------

function SetValueInDiv(DivID, ID, Value)
{
  // debugger;
  var formFieldList = getElementsByTagNames('hidden,input,select,textarea', document.getElementById(DivID));
  var FieldsCount = formFieldList.length;
  for (var i = 0; i < formFieldList.length; i ++ )
  {
    if  (formFieldList[i].id == ID)
    {
      formFieldList[i].value = Value;
      return true;
    }
  }
  return false;
}

//  ---------------------------------------

function GetValueInDiv(DivID, ID)
{
  var formFieldList = getElementsByTagNames('hidden,input,select,textarea', document.getElementById(DivID));
  var FieldsCount = formFieldList.length;
  for (var i = 0; i < formFieldList.length; i ++ )
  {
    if  (formFieldList[i].id == ID)
    {
      return formFieldList[i].value ;

    }
  }
  return "";
}

//  ---------------------------------------

function GetTopDivID(div)
{
  if (ifjQuery==false) {
    return 999;	
  }
  var aDivs = document.body.getElementsByTagName("DIV");
  var maxZ = 0;
  var tmpDiv;
  var currZ=0;
  if (aDivs.length > 0)
  {
    for (var i = 0; i < aDivs.length; i ++ )
    {
      tmpDiv = aDivs[i];
      if (tmpDiv.id == div)
      {
        continue;
      }
      currZ = parseInt($(tmpDiv).css( 'zIndex' ), 10);
      if ( currZ > maxZ)
      {
        maxZ = currZ;
      }
    }
  }
  return maxZ	;

}

//  ---------------------------------------

function getParamFromURL( name )
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}

//  ---------------------------------------

function getParamFromStr( name, tStr )
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp( regexS, "i" );
  var results = regex.exec(tStr );
  if( results == null )
  {
    return "";
  }
  else
    return results[1];
}

//  ---------------------------------------

function getMouseXY(e)
{
  if (IE)
  {
    // grab the x - y pos.s if browser is IE
    if (objectExists(document.body)) {
      tempX = event.clientX + document.body.scrollLeft;
      tempY = event.clientY + document.body.scrollTop;
    }
  }
  else
  {
    // grab the x - y pos.s if browser is NS
    tempX = e.pageX;
    tempY = e.pageY;
  }
  if (tempX < 0)
  {
    tempX = 0;
  }
  if (tempY < 0)
  {
    tempY = 0;
  }
  return true;
}

//  ---------------------------------------

function GetSum(xID)
{
  var i = 1;
  var result = 0;
  var eId = xID + i;
  var VarId = document.getElementById(eId);
  while (objectExists( VarId))
  {
    result = result + parseFloat(VarId.value);
    i = i + 1;
    eId = xID + i;
    VarId = document.getElementById(eId);
  }
  if (objectExists( xID))
  {
    document.getElementById(xID).value = Math.round(result);
  }
  return Math.round(result);
}

//  ---------------------------------------
function _close()
{
  if(document.getElementById("_iframe"))
  {
    document.getElementById("_iframe").firstChild.src = "about:blank";
    document.getElementById("_iframe").style.visibility = "hidden";
    document.getElementById("_iframe").style.display = 'none';
  }

  return true;
}

//  ---------------------------------------


function _show(_m)
{
  if(document.getElementById("_iframe"))
  {
    document.getElementById("_iframe").firstChild.src = "/images/" + _m;
    document.getElementById("_iframe").style.visibility = "visible";
    document.getElementById("_iframe").style.display = 'block';
  }

  return false;
}
function dOMgetHTML(el) {
  if (el.nodeType == 3) {       // Handle Text nodes
    return el.nodeValue;
  } else if (el.nodeType == 8) { // Handle Comments correctly
    return '<!--' + el.nodeValue + '-->';
  } else {
    var txt = new Array();
    var i=0;
    txt[txt.length] = '<' + el.tagName;   // Start creating tag
    if (el.attributes)
    {
      for (a=0;a<el.attributes.length;a++) {  // Add Attributes
        if (el.attributes[a].specified) {     // But only user Specified ones
          txt[txt.length] = ' ' + el.attributes[a].nodeName + '="' + el.attributes[a].nodeValue + '"';
        }
      }
    }
    if (el.childNodes.length > 0)
    //    if (el.childNodes)
    {
      txt[txt.length] = '>';
      while(el.childNodes[i]) {
        txt[txt.length] =  dOMgetHTML(el.childNodes[i]);
        i++;
      }
      txt[txt.length] =  '</' + el.tagName + '>';
    } else {
      txt[txt.length] =  '/>';
    }
  }
  return txt.join('');
}
//  ---------------------------------------

//if ( ! IE) document.captureEvents(Event.MOUSEMOVE)
//document.onmousemove = getMouseXY;

//  ---------------------------------------
function trim(str) {
  return str.replace(/^\s+|\s+$/g,"");
}
function StrToIntDef(str,DefValue) {
  if (isNaN(parseInt(str))) {
    return DefValue
  }
  else {
    return parseInt(str)
  }
	
}
	
function showAJAXDialog(DivName,url,title){   
  var aDivs;
  var FirstDiv;

  if (document.getElementById(DivName) === null)
  {
    myDiv = document.createElement('div');
    myDiv.setAttribute('id',DivName);
    //        myDiv.setAttribute('onclick',"this.style.display = 'none'");
    myDiv.innerText = "Please, wait ...";
    aDivs = document.body.getElementsByTagName("DIV");
    if (aDivs.length > 0) {
      FirstDiv = aDivs[0];
      FirstDiv.parentNode.insertBefore(myDiv,FirstDiv);
    }
    else {
      document.body.appendChild(myDiv);
    }
    if (ifjQueryui) {
      $( "#"+DivName ).dialog({
        autoOpen: false,
        height:"auto",
        width:"auto",
        hide:'slide',
        show:'slide' ,
        modal: true,
        dialogClass:"dialogaddSeasons"
      });
    } else {
      myDiv.setAttribute('style','display : block; padding:10px; top:20px; left:200px;position:fixed;background:#FFFFFF');
    }
  }
  if (ifjQuery) {
    $.get(url,
      function( data ) {
        if (ifjQueryui) {
          $( "#"+DivName ).html( data );
          $( "#"+DivName ).dialog( "option", "title", title );					
          $("#"+DivName).dialog('open'); 
        } else {
          loadHTMLFragment(DivName, data);  
          showDiv(DivName);    
        }

      });				  

  } else {
    showInfo(url  ,DivName);
    showDiv(DivName);
  }
}

function showDialog(SourceDivID,DestDivID,title,autoHideTimeout){   
  var aDivs;
  var FirstDiv;
  var xMessage;
  if (document.getElementById(SourceDivID)){
    xMessage= document.getElementById(SourceDivID).innerHTML;
  } else
{
    xMessage= SourceDivID;
  }
  if (document.getElementById(DestDivID) === null)
  {
    myDiv = document.createElement('div');
    myDiv.setAttribute('id',DestDivID);
    myDiv.innerText = "Please, wait ...";
    aDivs = document.body.getElementsByTagName("DIV");
    if (aDivs.length > 0) {
      FirstDiv = aDivs[0];
      FirstDiv.parentNode.insertBefore(myDiv,FirstDiv);
    }
    else {
      document.body.appendChild(myDiv);
    }
    if (ifjQueryui) {
      $( "#"+DestDivID ).dialog({
        autoOpen: false,
        height:"auto",
        width:"auto",
        hide:'slide',
        show:'slide' ,
        modal: true,
        dialogClass:"dialogaddSeasons"
      });
    } else {
      myDiv.setAttribute('style','display : block; padding:10px; top:20px; left:200px;position:fixed;background:#FFFFFF');
    }
  }
	
  if (ifjQueryui) {
    $( "#"+DestDivID ).html( xMessage );
    $( "#"+DestDivID ).dialog( "option", "title", title );					
    $("#"+DestDivID).dialog('open'); 
  }  

  else {
    document.getElementById(DestDivID).innerHTML = xMessage;
    showDiv(DestDivID);
  }
  if (autoHideTimeout){
    activeDivID = DestDivID;
    if (ifjQueryui) {
      setTimeout('$("#"+activeDivID).dialog("close"); ', autoHideTimeout);
            
    } else {
      setTimeout(' hideDiv(activeDivID) ', autoHideTimeout);
           
    }
  }
}


function showHint(SourceDivID,DestDivID,title,autoHideTimeout){   
  var aDivs;
  var FirstDiv;
  var xMessage;
  if (document.getElementById(SourceDivID))
  {
    xMessage= document.getElementById(SourceDivID).innerHTML;
  } 
  else
  {
    xMessage= SourceDivID;
  }
  if (document.getElementById(DestDivID) === null)
  {
    myDiv = document.createElement('div');
    myDiv.setAttribute('id',DestDivID);
    myDiv.innerText = "Please, wait ...";
    aDivs = document.body.getElementsByTagName("DIV");
    if (aDivs.length > 0) {
      FirstDiv = aDivs[0];
      FirstDiv.parentNode.insertBefore(myDiv,FirstDiv);
    }
    else {
      document.body.appendChild(myDiv);
    }
    var maxH=window.innerHeight-50;
    var maxW=window.innerWidth-240;
    myDiv.setAttribute('style','display : block;top:20px; left:200px;position:fixed; background-color:#FFFFCC; padding:10px;  border:1px solid #333; opacity:0.9; -moz-border-radius:6px; -webkit-border-radius:6px; -moz-box-shadow: 0 0 10px #ccc; -webkit-box-shadow: 0 0 10px #ccc; margin:auto;overflow:auto; max-height:'+maxH+'px;max-width:'+maxW+'px;');
  //    myDiv.setAttribute('style','display : block;top:20px; left:200px;position:fixed; background-color:#FFFFCC; padding:10px;  border:1px solid #333; opacity:1.0; -moz-border-radius:6px; -webkit-border-radius:6px; -moz-box-shadow: 0 0 10px #ccc; -webkit-box-shadow: 0 0 10px #ccc; margin:auto;overflow:auto; max-height:'+window.innerHeight-40+'px;max-width:'+maxW+'px;');
  }
  var prefix;
  prefix= '<div style="float: right; background-color: black; color: white; font-weight: bold; margin: -10px -10px 0px 10px; cursor: pointer; padding: 3px;" onclick="this.parentNode.style.display = \'none\'">';
  prefix= prefix+' X  </div>';
  prefix= prefix+'<div id="dHintData" style="float:left;border:2px solid #a1a1a1;padding:10px 40px; background:white;border-radius:25px;"  ondblclick="this.parentNode.style.display = \'none\'">';
  xMessage=prefix+ xMessage+' </div>';
  document.getElementById(DestDivID).innerHTML = xMessage;
  showDiv(DestDivID);
  if (autoHideTimeout){
    activeDivID = DestDivID;
    setTimeout(' hideDiv(activeDivID) ', autoHideTimeout);
           
  }
}

var activeDivID        ;

function selectText(element) {
  var doc = document;
  var text = doc.getElementById(element);    

  if (doc.body.createTextRange) { // ms
    var range = doc.body.createTextRange();
    range.moveToElementText(text);
    range.select();
  } else if (window.getSelection) { // moz, opera, webkit
    var selection = window.getSelection();            
    var range = doc.createRange();
    range.selectNodeContents(text);
    selection.removeAllRanges();
    selection.addRange(range);
  }
}

//$('.quickEdit').css('cursor','pointer');        
//$('.quickEdit').attr("onClick","fQuickEdit(this)");

var  edtValue=null;			
function fQuickEdit(el) 
{
  if (edtValue!=null){
    input.focus();
    input.select();	
    showHint('"Enter - to Save<br>Esc - to Cancel Edits.','dHint','',2000);
    return;
  //   fCancelEdit();
  }
  if (  el.type=="checkbox"){
    if (el.checked)
    {
      edtValue='0';
    }
    else
    {
      edtValue='1';
    }
  }
  else
  {
    edtValue=trim($(el).html());
  }
  $(el).attr("onClick","");
  var  addFunction= $(el).attr("addFunction");
  input = document.createElement('input');
  $(input).attr("type",'text');
  $(input).css("width",$(el).width()-2+'px');
  $(input).val(edtValue);
  $(input).attr("name", $(el).attr("name"));
  $(input).attr("onKeyDown",'fEndEdit(event,this)' );
		  

  $(el).html('<span  style="display:none;">'+edtValue+'</span>');
  el.appendChild(input);  
  if (  el.type=="checkbox")
  {
    showHint('<input type="button" value="Save" onclick="hideDiv(\'dHint\');fEndEdit(null,input);" /><input type="button" value="Cancel" onclick="hideDiv(\'dHint\');  fCancelEdit();" />','dHint','');
  }
  else {
    showHint('"Enter - to Save<br>Esc - to Cancel Edits.','dHint','',2000);
  
  
    input.focus();
    input.select();	
  }
  if (addFunction!= undefined){
    addFunction= addFunction + '(input)';
    eval(addFunction);
  }
}
		
		
function fEndEdit(evt,el)
{


  var currentKeyStroke  ;
  if (evt){
    currentKeyStroke = (document.all)? event.keyCode : evt.keyCode ;
  }
  else 
  {
    currentKeyStroke = 13
  }
  if (currentKeyStroke == 13 || el.type=="checkbox")
  {
    var tableToUpdate = fGetParentAttr(el,'tableName');
    var KeyValue =  fGetParentAttr(el,'key'); 	
    var KeyName = fGetParentAttr(el,'keyName'); 
    var updateURL =  fGetParentAttr(el,'updateURL'); 
    var Action =  fGetParentAttr(el,'Action'); 
	
    var FieldValue;
    if (	el.parentNode.type=="checkbox")
    {
      el=el.parentNode;     
    }
    uncolor=el.parentNode;
    if (el.type=="checkbox") 
    { 
            
      if (el.checked)
      {
        FieldValue =  '1';
      }
      else 
      {
        FieldValue =  '0';
      }
    }
    else
    {
      FieldValue =  el.value;	
    }
		
    $.post(updateURL, {
      Action: Action,
      TableName:tableToUpdate,
      KeyName:KeyName, 
      KeyValue:KeyValue,
      FieldName:el.name,
      FieldValue:FieldValue
    },
    function(data) {
      var oldbgCol = $(el.parentNode).css('background-color');
      if (data=='1' || data=='2' )
      {
        $(el.parentNode).css('background-color','#CCFFD9');
        setTimeout(" $(uncolor).css('background-color','"+oldbgCol+"');",700);
		   if ( data=='2' )
		   {
			   self.location=self.location;
		   }        
		   if (  el.type=="checkbox")
        {
          if (el.checked)
          {
			 
            edtValue='1'; 
          }
          else
          {
            edtValue='0';
          }
        } 
        else 
        {
          edtValue=$(el).val();
        }
      }
      else
      {
        if (  el.type=="checkbox")
        {
          if (el.checked)
          {
			 
            edtValue='0'; 
          }
          else
          {
            edtValue='1';
          }
        }

        $(el.parentNode).css('background-color','#FFBFBF');
        setTimeout(" $(uncolor).css('background-color','"+oldbgCol+"');",2000);
        showHint(data,'dHint','');
      }
    
      fCancelEdit();
    });					
 				 
  }			
  if (currentKeyStroke == 27 )
  {
    //   alert('Reset value:'+el.value);
    fCancelEdit();
  }			
				
}
		
function 	fCancelEdit()
{
		
  if (typeof(input)=='undefined' || input== null ){
    return
  }
  var el=input.parentNode;
  var p = $(input).detach();
  p=null;
	
  $(el).attr("onClick","fQuickEdit(this)");
  if (  el.type=="checkbox"){
    el.checked=edtValue=='1'; 
  }
  else
  {
    $(el).html(edtValue);  
  }
  edtValue=null;
  input=null;
}
			  
function fGetParentAttr(el,AttrName)
{
  var result ;
  while (result==undefined)
  {
    if (el.tagName=='BODY'){
      result= '';
      break;
    }
    result= $(el).attr(AttrName);
    el=el.parentNode;
  }
  return result;
}
